#ifndef ICONTHEMEWIDGET_H
#define ICONTHEMEWIDGET_H

#include "iconwidgetfeature.h"
#include "../fileProcess/filecheck.h"
#include "historywidget.h"
#include "basewidget.h"

#include <QWidget>
#include <QPushButton>
#include <QVBoxLayout>
#include <QButtonGroup>
#include <QPainter>
#include <QScrollArea>
#include <QLabel>
#include <QMap>
#include <QDebug>
#include <QFileDialog>
#include <QStackedWidget>
#include <QObject>
#include <QWidget>
#include <QTabBar>
#include <ktabbar.h>
class IconThemeWidget : public QWidget
{
    Q_OBJECT
public:
    explicit IconThemeWidget(bool isHistory,QWidget *parent = nullptr);
    void initPreviewWidget();
    void initEditWidget();
    void initSystemEditWidget();
    void initMaps();
    QMap<QString, QString> *getResourcesAppIconMap(QString Type);
    void initSystemMaps();
    void initRightWidget();
    QMap<QString, QString>* getAppIconsMap();
    QMap<QString, QString>* getSystemIconsMap();
    void setHistoryAppIcon();
    void setHistorySystemIcon();
    void updateCustomIconPathMap(QMap<QString, QString>*historyMap);
    void updateCustomSyetemIconPathMap(QMap<QString, QString>*historyMap);
    void eidtInitWidget(const HistoryInfo &InfoData);
    void refresh();

    static bool g_themeChange;
    QMap<QString, bool> *m_themeChangeMap;
    QMap<QString, bool> *m_iconPresenceMap;
signals:
    void wallpaperupdate(const QString& filePath);
    void newAppIconsMap(QMap<QString, QString> *appiconsmap);
    void newSystemIconsMap(QMap<QString, QString> *systemiconsmap);
    void iconthemeChange(QMap<QString, bool> *iconthemeChangeMap);
private:
    QStringList getWidgetNamesFromFilesInDirectory(const QString& directoryPath);

    QStackedWidget *m_themestackedwidget;
    QWidget *m_rightwidget;
    QVBoxLayout *m_rightwidgetlayout;
    QStackedWidget *m_stackedwidget;

    kdk::KTabBar *m_tabbar;
    QPushButton *m_appiconbtn;
    QPushButton *m_systemiconbtn;

    QMap<QString, QString> *m_iconpathmap;
    QMap<QString, QString> *m_historyiconmap;
    QMap<QString, QString> *m_customiconpathmap;
    QMap<QString, IconEditWidget*> *m_pathWidgetMap;

    QMap<QString, QString> *m_systemiconpathmap;
    QMap<QString, QString> *m_historysystemiconmap;
    QMap<QString, QString> *m_systemcustomiconpathmap;
    QMap<QString, IconEditWidget*> *m_systempathWidgetMap;

    BasePreviewWidget *m_previewwidget;
    ImageWidget *m_preview;
    ImageWidget *m_systempreview;
    QStackedWidget *m_previewstack;
    HistoryInfo m_info;
    QWidget *m_editwidget;
    QWidget *m_systemeditwidget;
};

#endif // ICONTHEMEWIDGET_H
